<!DOCTYPE HTML>
<html>
	<head>
		<script type="text/javascript" src="../Mr.async.js"></script>
		<script type="text/javascript">
			function asynFn(){
				var dfd = Mr.Deferred();
				setTimeout(function(){
					dfd.resolve(1, 1, 1, 1, 1);
				}, Math.random(1) * 2000);
				setTimeout(function(){
					dfd.reject(2, 2, 2, 2, 2);
				}, Math.random(1) * 2500);
				return dfd;
			}
			
			function asynFn2(){
				var dfd = Mr.Deferred();
				setTimeout(function(){
					dfd.resolve(33, 33, 33);
				}, Math.random(1) * 3000);
				return dfd;
			}

		window.onload = function(){		
			///*
			Mr.when( asynFn(), asynFn2() )
			.done(function(){
				console.log('when:done');
				console.log(arguments);
			})
			.fail(function(){
				console.log('when:fail');
				console.log(arguments);
			})
			.always(function(){
				console.log('when:always');
				console.log(arguments);
			})
			.then(
				function(){
					console.log('when:then->done');
					console.log(arguments);
				},
				function(){
					console.log('when:then->fail');
					console.log(arguments);
				});
			//*/
			/*
			asynFn()
			.done(function(){
				console.log('done');
				console.log(arguments);
			})
			.fail(function(){
				console.log('fail');
				console.log(arguments);
			})
			.then(
				function(){
					console.log('then->done');
					console.log(arguments);
				}, 
				function(){
					console.log('then->fail');
					console.log(arguments);
				})
			.always(function(){
				console.log('always');
				console.log(arguments);
			})
			.then(
				function(){
					console.log('then2->done');
					console.log(arguments);
				}, 
				function(){
					console.log('then2->fail');
					console.log(arguments);
				});
			*/
		}
		</script>
	</head>
	<body>
		<div id="log"></div>
	</body>
</html>